////////////////////////////////////////////////////////////////////////////////
//
//	Copyright (c) 2007 Robert L Sheely, inc. | http://www.robsheely.com
//
//	Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
//	documentation files (the "Software"), to deal in the Software without restriction, including without limitation
//	the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
//	to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//
//	The above copyright notice and this permission notice shall be included in all copies or substantial portions
//	of the Software.
//
//	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//	THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
//	TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
//	SOFTWARE.
//
////////////////////////////////////////////////////////////////////////////////

package CustomEvent
{
	/**
	 * A generic event class that allows the passing of additional parameters to event listeners.
	 *
	 * @author		robsheely
	 * 			rob@robsheely.com
	 * @url			http://robsheely.com
	 * @see			Event, Event Dispatcher
	 * @version		1.0.0
	 */
	
	import flash.events.Event;
	
	public class CustomEvent extends Event
	{
		protected var _data:Object;
		
		/**
		 * Constructor, creates new CustomEvent isntance.
		 *
		 * @param	type:String � The type of the event, accessible as Event.type.
		 * @param	bubbles:Boolean � Determines whether the Event object participates in the bubbling stage of the event flow.
		 * @default false
		 * @param	cancelable:Boolean � Determines whether the Event object can be canceled.
		 * @default false
		 * @param	data:Object - A Name-Value object for storing additional parameters to pass to event listeners, accessible as Event.data.
		 * @default null
		 * @example	To pass additional parameters to an event listener, dispatch an event such as this:<br /><br />
		 * var customData:Object = {width: 12, height: 14}
		 * <code>dispatchEvent(new CustomEvent('myCustomEventType', customData, false, false));</code><br />
		 * In the event listener, access the Event.data property:<br /><br />
		 * <code>protected function customEventListener(event:CustomEvent):void
		 * {
		 * 	this.width = data.width;
		 * 	this.height = data.height;
		 * }</code>
		 */
		public function CustomEvent(type:String,
											 data:Object = null,
											 bubbles:Boolean = false,
											 cancelable:Boolean = false)
		{
			_data = data;
			super(type, bubbles, cancelable);
		}
		
		/**
		 * The data property as set through the second parameter of the CustomEvent constructor. You can set as many properties as you want to pass to event listeners.
		 */
		public function get data():Object
		{
			return _data;
		}
	}
}